package com.axdac.mixbind.sql.db;

import android.content.Context;

import java.lang.reflect.Proxy;

@DB(DBname = "newdb",version = "1", CursorFactory = "", tableList = "")
public class DBHelper {
	private String DBname;
	private String version;
	private String CursorFactory;
	private String tableList;
	private Context context;

	public DBHelper(Context context){
		DB db = (DB)this.getClass().getAnnotation(DB.class);
		DBname = db.DBname();
		version = db.version();
		CursorFactory = db.CursorFactory();
		tableList = db.tableList();
		this.context = context;
	}

	public Object getDAO(Class<?> clazz) {
		Class[] classes = {clazz};
		ClassLoader loader = clazz.getClassLoader();
		DBInvo invo = new DBInvo(context,DBname,version,CursorFactory,tableList);
		return Proxy.newProxyInstance(loader, classes, invo);
	}
}
